vr2-6-04.wrl


[ VRML source code ]

#VRML V2.0 utf8
#vr2-6-04.wrl
Group {
  children  [
    DEF BarTouch TouchSensor {}
    Transform {
      children [
        Shape {
          appearance Appearance {
            material DEF BarColor1 Material {
              diffuseColor 1 1 0
            }
          }
          geometry Extrusion {
            creaseAngle 2
            beginCap FALSE
            endCap   FALSE
            crossSection [
              2 0, 1 -1.732, -1 -1.732, -2 0, -1 1.732, 1 1.732, 2 0
            ]  
            spine [
              0 0 0,   10 0 0,
              10 -10 0, 20 -10 0, 
              20 10 0,  30 10 0, 
              30 0 0,    40 0 0, 
              45 5 0, 55 -5 0, 
              70 -5 0, 
            ]
          }
        }
        Shape {
          appearance Appearance {
            material DEF BarColor2 Material {
              diffuseColor 1 1 0
            }
          }
          geometry Extrusion {
            creaseAngle 2
            beginCap FALSE
            endCap   FALSE
            crossSection [
              2 0, 1 -1.732, -1 -1.732, -2 0, -1 1.732, 1 1.732, 2 0
            ]  
            spine [
              0 -5 0,   5 -5 0,
              5 -15 0, 25 -15 0, 
              25 5 0,  25 5 0, 
              25 -5 0,    40 -7 0, 
              45 -2 0, 55 -12 0, 
              70 -12 0, 
            ]
          }
        }
      ]
    }
    DEF BarSwitch Script {
      eventIn  SFBool  isOver 
      eventOut SFColor color
      field    SFColor OnColor 1 0 1
      field    SFColor OffColor 1 1 0
      url "javascript:
        function isOver(b, eT) {
          if (b == true) color = OnColor;
          else           color = OffColor;
      }" 
    }
  ]
}
ROUTE BarTouch.isOver TO BarSwitch.isOver
ROUTE BarSwitch.color TO BarColor1.set_diffuseColor
ROUTE BarSwitch.color TO BarColor2.set_diffuseColor